package com.ujs.eduservice.controller.front;


import com.ujs.commonutils.constant.R;
import com.ujs.commonutils.utils.JwtUtils;
import com.ujs.eduservice.entity.subject.OneSubject;
import com.ujs.eduservice.entity.vo.frontVo.CommentVo;
import com.ujs.eduservice.service.EduCommentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.Arrays;
import java.util.Map;

/**
 * <p>
 * 评论 前端控制器
 * </p>
 *
 * @author testjava
 * @since 2023-09-03
 */
@RestController
@RequestMapping("/eduservice/educomment")
@Api(tags = "课程评论api")
public class EduCommentController {
    @Autowired
    private EduCommentService commentService;

    @ApiOperation("分页查询课程评论")
    @GetMapping("/getCommentList/{courseId}/{page}/{limit}")
    public R getCommentList(@PathVariable("courseId") String courseId,
                            @PathVariable("page") Long page,
                            @PathVariable("limit") Long limit) {
        Map<String, Object> map = commentService.getCommentList(courseId, page, limit);
        return R.ok().data(map);
    }

    @ApiOperation("添加课程评论")
    @PostMapping("/addComment")
    public R addComment(@RequestBody CommentVo commentVo, HttpServletRequest request) {
        // 评论内容，courseId，讲师id  详情页面都可以查询出来
        // 用户id，用户昵称，用户头像   远程调用 需要登录
        commentService.addComment(commentVo, request);
        return R.ok();
    }
}

